/*
 *  Arrow
 *
 *  Created by David Giovannini on 1/5/07.
 *  Copyright 2007 Software by Jove. All rights reserved.
 *
 */
 
#ifndef SBJ_Arrow_DequeuePolicy_h
#define SBJ_Arrow_DequeuePolicy_h

#include "SBJ/Arrow/Queue.h"

namespace SBJ
{

namespace Arrow
{

class DequeuePolicy
{
public:
	typedef Message::Priority Priority;

	enum ESide
	{
		eSide_none,
		eSide_front,
		eSide_back
	};

	struct Request
	{
		Request( void ) : dequeueFrom( Message::unknown_priority ), side( eSide_none ) {}

		Request( Priority from, ESide where ) : dequeueFrom( from ), side( where ) {}

		Priority dequeueFrom;
		ESide side;  
	};

	struct Range
	{
		Range( void ) : high( Message::highest_priority ), low( Message::lowest_priority ) {}

		Range( Priority h, Priority l ) : high( h ), low( l ) {}

		bool isInRange( Priority p ) const { return high <= p && p <= low; }

		Priority high;
		Priority low;
	};

	DequeuePolicy( void ) {}

	virtual ~DequeuePolicy( void ) {}

	virtual Range getRequiredPriority( void ) { return Range(); }

	virtual Request selectNode( Priority priority, const Queue::MsgLists& ) { return Request( priority, eSide_front ); }
};

}

}

#endif